package com.molyfun.parents.utils;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * Created by Administrator on 2017/11/19 0019.
 */

public class VerificationInfomationUtils {

    /**
     * @param email 邮箱信息
     * @return boolean
     */
    public static boolean isEmail(String email) {
        String str = "^([a-zA-Z0-9_\\-\\.]+)@((\\[[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.)|(([a-zA-Z0-9\\-]+\\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\\]?)$";
        Pattern p = Pattern.compile(str);
        Matcher m = p.matcher(email);
        return m.matches();

    }

    /**
     * @param mobiles 手机号码
     * @return boolean
     */
    public static boolean isMobileNO(String mobiles) {
        Pattern p = Pattern.compile("^((1[0-9][0-9])|(15[^4,\\D])|(17[0-9])|(18[0-9]))\\d{8}$");
        Matcher m = p.matcher(mobiles);
        return m.matches();
    }

    /**
     * @param identity 身份证号码
     * @return boolean
     */
    public static boolean isLegalId(String identity) {
        Pattern p = Pattern.compile("(^\\d{15}$)|(^\\d{17}([0-9]|X)$)");
        Matcher m = p.matcher(identity);
        return m.matches();
    }
}
